import { Sequelize } from "sequelize";

import ENV from "../env"
import { sqlLogger } from "../logger";

const sequelize = new Sequelize(ENV.MYSQL_DATABASE, "root", ENV.MYSQL_PASSWORD, {
  host: ENV.MYSQL_HOST,
  dialect: "mysql",
  port: +ENV.MYSQL_PORT,
  logging: (msg) => {
    sqlLogger.trace(msg)
  },
  define: {
    freezeTableName: true,
    updatedAt: true,
    createdAt: true,
  }
})

export default sequelize
